package Operation;
//增加图书
import Book.BookList;
import Book.Book;

import java.util.Scanner;

public class AddBook implements IOperation{
//先重写接口中的方法
    @Override
    public void work(BookList bookList) {
        if (bookList.getUsedBookList() == bookList.len){
            System.out.println("*****抱歉,书架满了,增加不了了*****");
            return;
        }
        //定义一个输入
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入所添加的书的名字:");
        String name = scanner.nextLine();

        System.out.println("请输入所添加的书的作者:");
        String author = scanner.nextLine();

        System.out.println("请输入所添加的书的价格:");
        double price = scanner.nextDouble();

        scanner.nextLine();

        System.out.println("请输入所添加的书的类型:");
        String type = scanner.nextLine();

        Book book = new Book(name,author,price,type);
        bookList.setBook(bookList.getUsedBookList(),book );
        bookList.setUsedBookList(bookList.getUsedBookList() + 1);
    }
}
